<template>
	<!-- 中国银行 -->
	<view>
		<view class="statusBar"></view>
		<view class="daohang">
			<view class="daohangicon" @tap="backBtn">❮</view>
			<view>交易明细</view>
			<view class="daohangicon"></view>
		</view>
		<view class="bankTit">
			<image src="../../static/bank-icon1.png" mode="widthFix"></image>
			<view class="bankTit-txt">
				<view>{{kaNum}}</view>
				<view>长城电子借记卡（ I 类账户）</view>
			</view>
		</view>
		<view class="time">
			<view>近6个月明细</view>
			<view>
				筛选
				<image src="../../static/bank-icon2.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="detailed">
			<view class="years">{{month}}月/{{year}}</view>
			<view class="detailedMain">
				<view v-for="(item,index) in list.list" :key="index">
					<view class="month">
						<view>{{item.showDate.substr(8,2)}}</view>
						<view>{{item.week}}</view>
					</view>
					<view>
						<view v-for="(item1,index) in item.list" :key="index" class="detailedList" @tap="delBtn" :data-id="item1.id">
							<view>
								<view>{{item1.payTypeStr}}</view>
								<view style="font-size: 3.4vw;color: #666666;">{{item1.name}}</view>
							</view>
							<view>
								<view>余额 {{item1.amount2}}</view>
								<view>人民币元<span :class="item1.payType==0?'myred':'mygreen'">{{item1.payType==0?'':'-'}}{{item1.showAmount}}</span></view>
							</view>
						</view>
						<!-- <view class="detailedList">
							<view>跨行转账</view>
							<view>
								<view>余额120.72</view>
								<view>人民币元<span>2,000,522.00</span></view>
							</view>
						</view> -->
					</view>
				</view>
				<!-- <view>
					<view class="month">
						<view>04</view>
						<view>周日</view>
					</view>
					<view>
						<view class="detailedList">
							<view>跨行转账</view>
							<view>
								<view>余额120.72</view>
								<view>人民币元<span>2,000,522.00</span></view>
							</view>
						</view>
						<view class="detailedList">
							<view>跨行转账</view>
							<view>
								<view>余额120.72</view>
								<view>人民币元<span>2,000,522.00</span></view>
							</view>
						</view>
						<view class="detailedList">
							<view>跨行转账</view>
							<view>
								<view>余额120.72</view>
								<view>人民币元<span>2,000,522.00</span></view>
							</view>
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	const http = require('../../utils/http.js');
	export default {
		data() {
			return {
				id:null,
				list:null,
				year:null,
				month:null,
				kaNum:null
			}
		},
		onLoad(options) {
			this.id=options.id
		},
		onShow() {
			var now = new Date();
			this.year = now.getFullYear(); //年
			if((now.getMonth() + 1) < 10){ //月
				this.month = '0'+(now.getMonth() + 1)
			}else{
				this.month = now.getMonth() + 1;
			}
			http.get('/api/balance/getBalanceDetail',{balanceId:this.id}).then(res => {
				//console.log(res.result.balance.bankCode)
				//console.log(res.result.balance.bankCode.replace(/^(\w{4})\w{10}(.*)$/, '$1***$2'))
				if (res.code == 200 && res.result) {
					this.list=res.result
					this.kaNum=res.result.balance.bankCode.replace(/^(\w{4})\w{11}(.*)$/, '$1****$2')
				}
			})
		},
		methods: {
			backBtn:function(){
				uni.navigateBack({
					delta: 1
				})
			},
			delBtn:function(e){
				var that=this
				uni.showModal({
				    title: '删除',
				    content: '确定删除该数据吗？',
				    success: function (res) {
				        if (res.confirm) {
				            //console.log(e.currentTarget.dataset.id);
							uni.showLoading({
							    title: '加载中'
							});
							http.get('/api/balance/delBalanceDetail',{balanceDetailId:e.currentTarget.dataset.id}).then(res => {
								uni.showToast({
								  title: res.message,
								  icon: 'none'
								});
								if(res.code==200){
									http.get('/api/balance/getBalanceDetail',{balanceId:that.id}).then(res1 => {
										if (res1.code == 200 && res1.result) {
											that.list=res1.result
										}
									})
								}
								uni.hideLoading();
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style>
	page{
		background: #e7eaef;
		font-family: 'jtfont-icon';
	}
	@font-face {
		font-family:jtfont-icon;
		src: url('~@/fonts/zhfont.ttf');
	}
	.statusBar{
		height: 8vw;
		background: #000000;
	}
	.myred{
		color: #ff6766;
	}
	.mygreen{
		color: #00c192;
	}
	.daohang{
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #333333;
		background: #FFFFFF;
		padding: 2.8vw 0;
	}
	.daohang .daohangicon{
		font-size: 5vw;
		width: 8%;
		text-align: center;
	}
	.daohang view:nth-child(2){
		text-align: center;
		font-weight: bold;
		font-family: sans-serif;
	}
	.bankTit{
		display: flex;
		margin: 2.8vw 2vw;
		padding: 3vw;
		background: #FFFFFF;
		align-items: center;
		border-radius: 1vw;
	}
	.bankTit image{
		width: 16vw;
		margin-right: 2.4vw;
	}
	.bankTit .bankTit-txt>view:nth-child(1){
		font-size: 4vw;
		font-weight: 550;
		color: #333333;
	}
	.bankTit .bankTit-txt>view:nth-child(2){
		font-size: 3.4vw;
		color: #666666;
	}
	.time{
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0 2.8vw 2.8vw 2.8vw;
		font-size: 3.4vw;
		color: #666666;
	}
	.time view:nth-child(2){
		display: flex;
		align-items: center;
	}
	.time image{
		width: 3.4vw;
		margin: 0 2vw;
	}
	.detailed{
		display: flex;
		flex-direction: column;
	}
	.detailed .years{
		width: 100%;
		padding: 2vw 3vw;
		background: #f8f8f8;
		color: #8d9aa0;
		font-size: 3.4vw;
		border-bottom: 1px solid #F2F2F2;
		border-top: 1px solid #F2F2F2;
	}
	.detailedMain{
	}
	.detailedMain>view{
		display: flex;
		flex-direction: row;
	}
	.detailedMain .month{
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 3vw;
		background: #f1f5f4;
		color: #8d9aa0;
	}
	.detailedMain>view>view:nth-child(2){
		flex: 1;
	}
	.detailedMain .month>view:nth-child(1){
		font-size: 4.4vw;
		font-weight: bold;
	}
	.detailedMain .month>view:nth-child(2){
		font-size: 3vw;
	}
	.detailedList{
		background: #FFFFFF;
		padding: 3vw;
		border-bottom: 1px solid #F2F2F2;
	}
	.detailedList>view:nth-child(1){
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 3.8vw;
		color: #333333;
		margin-bottom: 1.2vw;
	}
	.detailedList>view:nth-child(2){
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		font-size: 3.4vw;
		color: #666666;
	}
	.detailedList>view:nth-child(2)>view:nth-child(2){
		color: #333333;
	}
	.detailedList>view:nth-child(2)>view:nth-child(2) span{
		font-weight: 600;
		margin-left: 0.8vw;
	}
</style>
